﻿using System;
using System.IO;

namespace LunoCode
{
	static class Program
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		static void Main(string[] args)
		{
			AppDomain.CurrentDomain.UnhandledException += ExceptionHandler;
			using (LunoGame game = new LunoGame())
			{
				game.Run();
			}
		}
		static void ExceptionHandler(object sender, UnhandledExceptionEventArgs e)
		{
			FileInfo fi = new FileInfo("debug");
			StreamWriter sw = fi.CreateText();
			sw.WriteLine(((Exception)e.ExceptionObject).Message);
			sw.WriteLine(((Exception)e.ExceptionObject).StackTrace);
			Exception root = ((Exception)e.ExceptionObject).GetBaseException();
			sw.WriteLine("----ROOT----");
			sw.WriteLine(root.Message);
			sw.WriteLine(root.StackTrace);
			sw.Close();
		}
	}
}

